package code.java.text;

import java.text.DecimalFormat;

/**
 * Created by chopin on 17/12/15.
 * java.text.DecimalFormat
 */
public class DecimalFormatTest {

    public static void main(String args[]) {
        DecimalFormatTest t = new DecimalFormatTest();
        t.test1(new Double(1200.0));//1200
        t.test1(new Double(1200.01));//1200.01
        t.test1(new Double(1200.011));//1200.01
        t.test1(4.01E12);//4010000000000

    }

    public void test1(Double d) {
        DecimalFormat decimalFormat = new DecimalFormat("#.##");
        String str = decimalFormat.format(d);
        System.out.println(str);
    }

    public  void test2(){
        DecimalFormat decimalFormat = new DecimalFormat("");
    }

}
